﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using eShop.Business;
using Ext.Net;

using eShop.Model;
using eShop.Business;

public partial class admin_manufacturer_list : SiteAdminBasePage
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        uccResponseMessage.Visible = false;

    }
    protected void Store1_RefreshData(object sender, StoreRefreshDataEventArgs e)
    {
        BindSupplier(e.Sort + (e.Dir.ToString() == "Default" ? "" : " " + e.Dir), e.Start, e.Limit);
    }

    protected void imgSearchButton_Click(object sender, EventArgs e)
    {

    }

    private void BindSupplier(string sort, int start, int limit)
    {
        List<Manufacturer> data = null;
        int totalCount = 0;
        if (String.IsNullOrEmpty(sort))
            sort = "ProductBrandId";
        data = ManufacturerManager.GetBackendBrandList(sort, start, limit);
        totalCount = ManufacturerManager.GetBackendBrandListCount();

        Store1.DataSource = data;
        Store1.DataBind();

        (Store1.Proxy[0] as PageProxy).Total = totalCount;
    }

   
    [DirectMethod(Namespace = "EShop.WebService")]
    public void DeleteSupplier(string ids)
    {
        ids = ids.TrimStart(' ');
        string[] idArray = ids.Split(' ');
        List<int> idList = new List<int>();
        foreach (string id in idArray) idList.Add(Convert.ToInt32(id));
        ManufacturerManager.DeleteBrands(idList);
        Store1.DataBind();
    }

}